package cn.mayaslight.wechat.api;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import cn.mayaslight.common.annotation.HttpWithParam;
import cn.mayaslight.common.exception.HandleException;
import cn.mayaslight.common.springbean.APICaller;
import cn.mayaslight.wechat.api.params.WithTokenParam;


public class MediaAPI extends BaseAPI{

	/**
	 * 下载多媒体
	 * 视频文件不支持下载
	 * @param access_token
	 * @param media_id
	 * @return
	 */
	public static byte[] mediaGet(final String mediaId, final boolean isQy){
		try {
			HttpResponse httpResponse = APICaller.call(new WithTokenParam() {
				
				@HttpWithParam("media_id")
				private String _mediaId = mediaId;
				
				public String getApiKey() {
					return isQy ? "" : "";
				}
			});
			return EntityUtils.toByteArray(httpResponse.getEntity());
		} catch (Exception e) {
			throw new HandleException(e);
		}
	}

}
